package nc.vo.pu.metsettle.entity;

import nc.vo.pub.CircularlyAccessibleValueObject;
import nc.vo.pubapp.pattern.model.entity.bill.AbstractBill;
import nc.vo.pubapp.pattern.model.meta.entity.bill.BillMetaFactory;
import nc.vo.pubapp.pattern.model.meta.entity.bill.IBillMeta;
import nc.vo.trade.pub.IExAggVO;

@nc.vo.annotation.AggVoInfo(parentVO = "nc.vo.pu.metsettle.entity.MetSettleBillHeaderVO")

public class AggMetSettleBillHeaderVO extends AbstractBill implements IExAggVO {

	private static final long serialVersionUID = -187699006835286729L;

	@Override
	public IBillMeta getMetaData() {
		IBillMeta billMeta = BillMetaFactory.getInstance().getBillMeta(AggMetSettleBillHeaderVOMeta.class);
		return billMeta;
	}

	@Override
	public MetSettleBillHeaderVO getParentVO() {
		return (MetSettleBillHeaderVO) this.getParent();
	}

	public MetSettleBillItemVO[] getItemVO() {
		return (MetSettleBillItemVO[]) getChildren(MetSettleBillItemVO.class);
	}

	public MetSettleBillSourceItemVO[] getSourceItemVO() {
		return (MetSettleBillSourceItemVO[]) getChildren(MetSettleBillSourceItemVO.class);
	}

	@Override
	public String[] getTableCodes() {
		String[] codes = new String[2];
		codes[0] = "pk_settlebill_b";
		codes[1] = "pk_settlebill_s";
		return codes;
	}

	@Override
	public String[] getTableNames() {
		String[] codes = new String[2];
		codes[0] = "pk_settlebill_b";
		codes[1] = "pk_settlebill_s";
		return codes;
	}

	public void setItemVO(MetSettleBillItemVO[] item) {
		setChildren(MetSettleBillItemVO.class, item);
	}

	public void setSourceItemVO(MetSettleBillSourceItemVO[] sourceItem) {
		setChildren(MetSettleBillSourceItemVO.class, sourceItem);
	}

	public void setParentVO(MetSettleBillHeaderVO hvo) {
		setParent(hvo);
	}

	public void setTableVO(String tableCode, CircularlyAccessibleValueObject[] values) {
		if ("met_settlebill_b".equalsIgnoreCase(tableCode) || "pk_settlebill_b".equalsIgnoreCase(tableCode)) {
			this.setItemVO((MetSettleBillItemVO[]) values);
		} 
		if ("met_settlebill_s".equalsIgnoreCase(tableCode) || "pk_settlebill_s".equalsIgnoreCase(tableCode)) {
			this.setSourceItemVO((MetSettleBillSourceItemVO[]) values);
		}
	}
	
	public CircularlyAccessibleValueObject[] getTableVO(String tableCode) {
	    if ("met_settlebill_b".equalsIgnoreCase(tableCode) || "pk_settlebill_b".equalsIgnoreCase(tableCode)) {
	      return this.getItemVO();
	    }
	    if ("met_settlebill_s".equalsIgnoreCase(tableCode) || "pk_settlebill_s".equalsIgnoreCase(tableCode)) {
	      return this.getSourceItemVO();
	    }
	    return null;
	  }

}